<tagLib name="html" />
<include file="Public:headerNew" />
<load href="__PUBLIC__/Js/JqueryUI/jquery-ui-1.8.20.custom.min.js" />
<load href="__PUBLIC__/CSS/JqueryUI/jquery-ui-1.8.20.custom.css" />
<load href="__PUBLIC__/Js/Jquery/jquery.form.js" />
<div class="titleone"><h1 class="fLeft">添加商业用户信息</h1><a href="__URL__"><div class="returnimg"></div></a></div>
<div id="result" class="result none"></div>
<div id="main" class="main full" >


		<script type="text/javascript">
			var places=new Array();
			//占用面积值
			var placeValue = 0.0;
			var zlist='';
			$(function(){
	       		function checkForm(){

							if( '' == $.trim($('#name').val())){
											
									$('#result').html('名字不能为空').show();
							
											return false;
							
							}
							
							if('' == $.trim(zlist)){
								$('#result').html('未指定位置').show();
						
									return false;
											
							}
			

							

								
							//可以在此添加其它判断
		
						}
				//check 部分			
				$('body').addClass('has-js');
				 $('.label_check,.label_radio').click(function(){ setupLabel(); });
			  	setupLabel();

				$('#dialog').dialog({

					autoOpen: false,


					width: 260,
					modal : true,
					
					buttons: {

						"添加": function() { 
							moveOption(document.getElementById('zonesel'),document.getElementById('myzone'),0);

						}, 

						"关闭": function() { 

							$(this).dialog("close"); 

						} 

					}

				});

				

				// Dialog Link

				$('#addbuttonBlock').click(function(){

					$('#dialog').dialog('open');

					return false;

				});





				



				

				//hover states on the static widgets

				$('#dialog_link, ul#icons li').hover(

					function() { $(this).addClass('ui-state-hover'); }, 

					function() { $(this).removeClass('ui-state-hover'); }

				);

				

			});
			function submitForm() { 
									// inside event callbacks 'this' is the DOM element so we first 
									// wrap it in a jQuery object and then invoke ajaxSubmit 
							//添加地区信息
						$('#zArraylist').val(zlist);
						$('#form1').submit();
       					return false;	
								
   			};
			
			
			
			function getZonsList(obj){
				var t_url = "{:U('getZoneList?pid=')}"+$("#zoneid").val();
				$.ajax({
						url: t_url,
						type: 'GET',
						dataType: 'json',
						error: function(){
							alert('Error loading XML document');
						},
						success: function(data, textStatus){
							var json = eval(data['data']);
							$('#zonesel').empty();
							places = [];
							
							json.sort(function(a,b){
    								return a.id-b.id;
							});
						    for (var ind in json) {
							 	 $('#zonesel').append('<option value="' + json[ind].id + '">'+ json[ind].name + '</option>');
								 //对面积数据数组赋值
									var itemx= new Array();
									itemx[0]=json[ind].id;
									itemx[1]=json[ind].name;
									itemx[2]=json[ind].place;
									places[ind] = itemx;
	                		}
						}
				});
			} 
			function moveOption(obj1,obj2,type)
			{
				zlist='';
				for(var i = obj1.options.length - 1 ; i >= 0 ; i--)
				{
					if(obj1.options[i].selected)
					{
							var opt = new Option(obj1.options[i].text,obj1.options[i].value);
							opt.selected = true;
							//加面积
							for(var x = places.length - 1 ; x >= 0 ; x--){
								if (places[x][0]==obj1.options[i].value){
									if (type==0){
			
										placeValue=placeValue+Number(places[x][2]);	
										
										showPlace();
									
									}else if  (type==1){
										
										placeValue = placeValue-Number(places[x][2]);

										showPlace();	
									
									}
									
								}
							}
							
							
							
							
							obj2.options.add(opt);
							obj1.remove(i);
							
							
					}
				 }
				// getzLists();
				 sortMe(obj1);
				 sortMe(obj2);
			}
			//更新显示面积值
			function showPlace(){
				$('#zplace').val(placeValue.toString());

			}


			//select 排序
			function sortMe(oSel){
				var ln = oSel.options.length;
				var arr = new Array(); // 这是关键部分

				// 将select中的所有option的value值将保存在Array中
				for (var i = 0; i < ln; i++)
				{
				 
				  // 如果需要对option中的文本排序，可以改为arr[i] = oSel.options[i].text;
				  var item = new Array();
				  item[0] = oSel.options[i].value;
				  item[1] = oSel.options[i].text;
				  arr[i] = item;
				}
				 
				arr.sort(function(a,b){ // 开始排序
						//a 价格

					var aValue=a[0];
						//b 价格
					var bValue=b[0];

					
						//升序
						return aValue-bValue;
						//降序
						//return bValue-aValue;
					
					});

				 
				// 清空Select中全部Option
				 
				while (ln--)
				{
				  oSel.options[ln] = null;
				}
				 
				// 将排序后的数组重新添加到Select中
				for (i = 0; i < arr.length; i++)
				{ 

					oSel.options.add (new Option(arr[i][1],arr[i][0]));
					if (oSel.id=='myzone'){
						zlist=arr[i][0]+','+zlist;
					
					}

				}
				
			
			}
</script>




<form method='post' id='form1' action='__URL__/insertBiz'  enctype="multipart/form-data">



		<!-- ui-dialog -->

<div class="metroTitle">添加新的商业机构</div>		
<ul class="pt_list" id="pt_list">

          <li style="height:300px;">

                    <div class="thumb"></div>

                    <h3>基本信息</h3>

                    <div class="thumbr">
<table width="900" cellpadding=3 cellspacing=3 >
<tr>
	<td width="99" height="24" class="tRight" >商户名称：</td>
	<td width="388" class="tLeft" ><input type="text"  name="name" id="name"></td>
	<td width="155" align="left" class="tLeft" ><span class="tRight">位置信息</span><html:select name="pid" id="zoneid" change="getZonsList(this)" first="选择区域" options="zonesList" selected="selectZoneGroupId" /></td>
	<td width="217" class="tLeft" ></td>
</tr>

<tr>
  <td height="24" class="tRight">使用面积：</td>
  <td class="tLeft"><input name="" type="text" id="zplace" value="0" /></td>
  <td rowspan="4" align="left" valign="top" class="tLeft">
  
    <select name="myzone" size="6" multiple="multiple" id="myzone" class="zonelist">
    </select></td>
  <td align="left" valign="top" class="tLeft"><a id="addbuttonBlock" href="javascript:zonelist(1)"></a>
  <div id="dialog" title="选择区域">

<br />
<select name="zoneid2" size="10" multiple="multiple" id="zonesel"  style="width:160px;height:160px;" >
</select>
</div>
  </td>
</tr>
<tr>
	<td height="24" class="tRight">状态：</td>
	<td class="tLeft"><select name="status">
	  <option value="1">启用</option>
	  <option value="0">禁用</option>
	  </select></td>
	<td align="left" class="tLeft"><a id="reducebuttonBlock" href="javascript:moveOption(document.getElementById('myzone'),document.getElementById('zonesel'),1);"></a></td>
</tr>
<tr>
	<td class="tRight tTop">描 述：</td>
	<td align="left" class="tLeft"><TEXTAREA  name="remark"  ROWS="3" COLS="50" id="remark"></TEXTAREA></td>
	<td align="left" class="tLeft">&nbsp;</td>
</tr>
<tr>
	<td >地址：</td>
	<td align="left" class="center"><span class="tLeft">
	  <textarea  name="address"  rows="1" cols="50" id="address"></textarea>
	</span></td>
	<td class="center">&nbsp;</td>
</tr>
</table>
</div>
</li>
<li><div class="title_Text">联系人信息</div>
<div class="Src_Text">
  <table width="98%" cellpadding="3" cellspacing="3" >
    <tr>
      <td width="193" class="tRight" >联系人：</td>
      <td width="282" class="tLeft" ><input type="text" class="medium bLeftRequire"  name="contact"  id="contact"/></td>
      <td width="877" class="tLeft" >&nbsp;</td>
      <td width="218" class="tLeft" >&nbsp;</td>
    </tr>
    <tr>
      <td class="tRight">联系电话：</td>
      <td class="tLeft"><input type="text" class="medium bLeftRequire"  name="tel" id="tel" /></td>
      <td class="tLeft">&nbsp;</td>
      <td class="tLeft">&nbsp;</td>
    </tr>
  </table>

                    </div>


            </li>
            </ul>
<ul class="grouparry">
<li>
<div class="title_Text">商户基本信息</div>
<div  class="Src_Text">

</div>
</li>
<li>
<div class="title_Text">服务开通信息</div>
<div class="Src_Text">
<script language="javascript">
    function setupLabel(){ if($('.label_check input').length) { 
		$('.label_check').each(function(){ $(this).removeClass('c_on'); });
		 $('.label_check input:checked').each(function(){ $(this).parent('label').addClass('c_on'); }); }; 
		 if($('.label_radio input').length) { $('.label_radio').each(function(){ $(this).removeClass('r_on'); });
		  $('.label_radio input:checked').each(function(){ $(this).parent('label').addClass('r_on'); }); }; 
	}
   </script>
 <fieldset class="checkboxes">
      <table width="900" border="0">
		  <tr>
		    <td width="150"><label for="checkbox-01" class="label_check"> <input type="checkbox" value="1" checked="checked" id="checkbox-01" name="sample-checkbox[]" />水费 </label></td>
		    <td width="150"><label for="checkbox-02" class="label_check"> <input type="checkbox" value="2" checked="checked" id="checkbox-02" name="sample-checkbox[]" />电费</label> </td>
		    <td width="150"><label for="checkbox-03" class="label_check"> <input type="checkbox" value="3" checked="checked" id="checkbox-03" name="sample-checkbox[]" />物业费</label> </td>
		    <td width="150"><label for="checkbox-04" class="label_check"> <input type="checkbox" value="4" checked="checked" id="checkbox-04" name="sample-checkbox[]" />污水处理费</label></td>
		    <td width="150"><label for="checkbox-05" class="label_check"> <input type="checkbox" value="5" checked="checked" id="checkbox-05" name="sample-checkbox[]" />采暖费</label></td>
		    <td width="150">&nbsp;</td>
	    </tr></table>
      </fieldset>
</div>
</li>
<li>
<div class="title_Text">费用单价信息</div>
<div class="Src_Text">
<table width="900" border="0">
  <tr>
    <td>水费单价</td>
    <td><span class="tLeft">
      <input type="text" class="medium bLeftRequire"  name="water"  id="water" value="<php>echo $setting['water'];</php>"/>
    </span></td>
    <td>电费单价</td>
    <td><span class="tLeft">
      <input type="text" class="medium bLeftRequire"  name="electricity"  id="electricity" value="<php>echo  $setting['electricity'];</php>"/>
    </span></td>
    <td>物业费单价</td>
    <td><span class="tLeft">
      <input type="text" class="medium bLeftRequire"  name="property"  id="property" value="<php>echo  $setting['property'];</php>"/>
    </span></td>
  </tr>
  <tr>
    <td>污水处理费单价</td>
    <td><span class="tLeft">
      <input type="text" class="medium bLeftRequire"  name="wastewater"  id="wastewater" value="<php>echo $setting['wastewater'];</php>"/>
    </span></td>
    <td>采暖费单价</td>
    <td><span class="tLeft">
      <input type="text" class="medium bLeftRequire"  name="heating"  id="heating" value="<php>echo $setting['heating'];</php>"/>
    </span></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</div></li>
</ul>

<div class=cssClear></div>
    <div class="toolPanel">
        <div style="width:99%;margin:5px">
            <input type="hidden" name="zArraylist" id="zArraylist" value="2">
             <div class="impBtnN fRig"><a href="#" onclick="document.forms['form1'].reset()" id="buttonclearBlock" ></a></div>
            <div class="impBtnN fRig"><a href="#" onclick="submitForm();" id="buttonSaveBlock" ></a></div>
</form>           
        </div>
    </div>

</div>